#include <Python.h>

PyObject *wrap_power(PyObject *self, PyObject *args) {
	int result, n;
	if(!PyArg_ParseTuple(args, "i:power", &n)) {
		return NULL;
	}
	result = power(n);
	return Py_BuildValue("i", result);
}

PyObject *wrap_add_int(PyObject *self, PyObject *args) {
	int result, a, b;
	if(!PyArg_ParseTuple(args, "ii:add_int", &a, &b)) {
		return NULL;
	}
	result = add_int(a, b);
	return Py_BuildValue("i", result);
}

PyObject *wrap_my_print(PyObject *self, PyObject *args) {
	char *s = NULL;
	if(!PyArg_ParseTuple(args, "s:my_print", &s)) {
		Py_INCREF(Py_None);
		return Py_None;
	}
	my_print(s);
	Py_INCREF(Py_None);
	return Py_None;
}

PyObject *wrap_whoami(PyObject *self, PyObject *args) {
	whoami();
	Py_INCREF(Py_None);
	return Py_None;
}

static PyMethodDef examMethods[] = {
	{"power", wrap_power, METH_VARARGS, "calculate power"},
	{"add_int", wrap_add_int, METH_VARARGS, "add int"},
	{"my_print", wrap_my_print, METH_VARARGS, "print string"},
	{"whoami", wrap_whoami, METH_VARARGS, "who am i"},
	{NULL, NULL, 0, NULL}
};

void initexam() {
	PyObject *m = Py_InitModule("exam", examMethods);
}
